package com.cloud.poetry.system.manager;

import com.cloud.poetry.base.anno.DataSource;
import com.cloud.poetry.core.constant.DataSourceEnum;
import com.cloud.poetry.system.mapper.DemoMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 这里主要看@DataSource的用法
 * @author mengxj
 */
@Slf4j
@Service
public class DemoManager {

    @Resource
    private DemoMapper demoMapper;

    public List<String> tables1(){
        log.info("get tables from first datasource ...");
        return this.demoMapper.tables();
    }

    @DataSource(DataSourceEnum.SECOND)
    public List<String> tables2(){
        log.info("get tables from second datasource ...");
        return this.demoMapper.tables();
    }
}
